package com.truesai.entities.employee;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.Max;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import com.truesai.dto.Gender;


/**
 * 员工详细信息<br/>
 * 需求分析<br/>
 * <strong>唯一性:</strong>身份证号码
 * @author XuLian
 */
@Entity
@NamedQueries(
{
        @NamedQuery(name = Employee.ALL, query = "Select e from Employee e"),
        @NamedQuery(name = Employee.BY_EMPLOYEENAME, query = "Select e from Employee e where e.name = :name"),
        @NamedQuery(name = Employee.BY_ID, query = "Select e from Employee e where e.id = :id") })
@Table(name = "employees")
public class Employee
{

    public static final String ALL = "Employee.all";

    public static final String BY_EMPLOYEENAME = "Employee.byEmployeeName";

    public static final String BY_ID = "Employee.byId";

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**员工姓名*/
    @Column(nullable = false)
    @NotNull
    @Size(min = 2, max = 64)
    private String name;
    
    /**员工性别*/
    @Column
    @Enumerated(EnumType.ORDINAL)
    private Gender gender;
    /**年龄*/
    @Column
    @Max(150)
    private Integer age;
    
    /**身份证*/
    @Column
    @Size(min=15, max = 18)
    private String idcard;
    
    /**籍贯*/
    @Column
    @Size(min=1, max=50)
    private String nativePlace;
    
    public Employee() { }
    
    public Employee(String name, Gender gender, Integer age, String idcard, String nativePlace){
    	this.name = name;
    	this.gender = gender;
    	this.age = age;
    	this.idcard = idcard;
    	this.nativePlace = nativePlace;
    }


    @Override
    public String toString() {
        return name;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getUsername() {
        return name;
    }

    public void setUsername(String username) {
        this.name = username;
    }


	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Gender getGender() {
		return gender;
	}

	public void setGender(Gender gender) {
		this.gender = gender;
	}

	public Integer getAge() {
		return age;
	}

	public void setAge(Integer age) {
		this.age = age;
	}

	public String getIdcard() {
		return idcard;
	}

	public void setIdcard(String idcard) {
		this.idcard = idcard;
	}

	public String getNativePlace() {
		return nativePlace;
	}

	public void setNativePlace(String nativePlace) {
		this.nativePlace = nativePlace;
	}

}